local wdtx__ironChainCardSkill = fk.CreateSkill {
  name = "wdtx__iron_chain_skill",
}

wdtx__ironChainCardSkill:addEffect("cardskill", {
  name = "wdtx__iron_chain_skill",
  prompt = "#wdtx__iron_chain_skill",
  min_target_num = 1,
  max_target_num = function(self,card)
    if card:getMark("@rechain_num") > 0 then
      return 3
    end
    return 2
  end,
  mod_target_filter = Util.TrueFunc,
  target_filter = function(self, player, to_select, selected, a, card)
    if #selected < self:getMaxTargetNum(player, card) + card:getMark("@rechain_num") then
      return self:modTargetFilter(to_select, selected, player, card)
    end
  end,
  on_effect = function(_, room, effect)
    local to = effect.to
    if room.logic.class.name == "wdtx_logic" and effect.card:getMark("@@alone_facedown") > 0 and #effect.tos == 1 then
      to:turnOver()
    end
    to:setChainState(not to.chained)
  end,
})


return wdtx__ironChainCardSkill